package com.cskaoyan.mapper;

import com.cskaoyan.bean.Order;
import com.cskaoyan.bean.OrderExample;
import com.cskaoyan.bean.WXOrderCommentId;
import jdk.internal.instrumentation.InstrumentationTarget;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.List;

public interface OrderMapper {
    long countByExample(OrderExample example);

    int deleteByExample(OrderExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Order record);

    int insertSelective(Order record);

    List<Order> selectByExample(OrderExample example);

    Order selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Order record, @Param("example") OrderExample example);

    int updateByExample(@Param("record") Order record, @Param("example") OrderExample example);

    int updateByPrimaryKeySelective(Order record);

    int updateByPrimaryKey(Order record);

    int cancelOrder(@Param("orderId") Integer orderId);

    int updateShipInfo(@Param("shipSn") String shipSn, @Param("shipChannel") String shipChannel, @Param("orderId") Integer orderId);


    List<Order> selectOrdersByTimeScope(@Param("start") String start, @Param("end") String end);

    List<Order> selectOrders(@Param("orderSn") String orderSn,@Param("orderStatusArray") Integer orderStatusArray,
                             @Param("userId") Integer userId,@Param("sort")String sort,@Param("order") String order);

    @Update("Update cskaoyanmall_order " +
            "set order_status = #{status},deleted = true, end_time =#{time}  " +
            "where deleted = false and id =#{orderId}")
    int ChangeDeleteStatusById(@Param("orderId") Integer orderId, @Param("time") Timestamp time, @Param("status") Integer i);

    @Update("Update cskaoyanmall_order " +
            "set order_status = #{status}, update_time =#{time}  " +
            "where deleted = false and id =#{orderId}")
    int changeStatusById(@Param("orderId") Integer orderId, @Param("time") Timestamp time, @Param("status") Integer i);

    int addContent(@Param("content") String content, @Param("hasPicture") Boolean hasPicture,
                   @Param("orderGoodsId") Integer orderGoodsId, @Param("star") Integer star,
                   @Param("picUrls") String picUrls, @Param("addTime") Timestamp addTime, @Param("id") WXOrderCommentId commentId, @Param("userId") Integer id);

    @Select("select max(id) from cskaoyanmall_order")
    int getMaxId();
}
